#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
	int a, b, min;
	scanf("%d %d", &a, &b);
	if (a < b)
		min = a;
	else
		min = b;
	for (int i = min; i > 0; i--)
	{
		if(0 == a%i && 0 == b%i)
		{
			printf("%d\n", i);
		}
		return 0;
	}
}